package lambda;

public class LambdaDemo {
    public static void main(String[] args) {
//        MyRunnable myRunnable = new MyRunnable();
//        Thread thread = new Thread(myRunnable);
//        thread.start();

        //匿名内部类改进
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("start runnable");
//            }
//        }).start();

        //lambda改进

//        new Thread( () -> {
//            System.out.println("start");
//        } ).start();

        useFlyable( s ->{
            System.out.println(s);
        });
        //如果参数有且仅有一个小括号也可以省
        useAddable((x,y) -> x+y);

        useInter(() -> System.out.println("good"));

    }
    private static void useInter(Inter inter){
        inter.show();

    }
    private static void useFlyable(Flyable flyable) {
        flyable.fly("sun and night");
    }
    private static void useAddable(Addable addable) {
        int sum = addable.add(10, 20);
        System.out.println(sum);
    }
}
